<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>交集，差集，并集</title>
</head>
<body>
    
</body>
</html>

<script>
    let hd = new Set(['hdcms','houdunren','后盾人']);
    let cms = new Set(['后盾人','hdcms']);

    //获取两个集合中共同存在的元素
    // let newSet = new Set(
    //     [...hd].filter((item) => cms.has(item))
    // );
    // console.log(newSet)

    //获取两个集合的差集
    // let newSet = new Set(
    //     [...hd].filter((item) => !cms.has(item))
    // );
    // console.log(newSet);

    //获取两个集合的并集
    let newSet = new Set(
        [...hd,...cms]
    );
    console.log(newSet);
    
</script>